<!DOCTYPE html>
<html>

<head>
    <title>找回密码</title>
    <meta charset="utf-8"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="${ctxPath}/assets/common/layui/css/layui.css"/>
    <link rel="stylesheet" href="${ctxPath}/assets/common/css/login.css" media="all">
    <style>
        body {
            background-image: url("${ctxPath}/assets/common/images/bg_login2.svg");
            background-position: center 110px;
            background-repeat: no-repeat;
            background-size: 100%;
            background-color: #f0f2f5;
        }

        .login-header {
            color: rgba(0, 0, 0, .85) !important;
        }

        .login-footer {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a {
            color: rgba(0, 0, 0, 0.7) !important;
        }

        .login-footer a:hover {
            color: rgba(0, 0, 0, 0.4) !important;
        }

        .login-body > .layui-card {
            max-width: 450px;
        }

        .login-body .layui-form-pane .layui-form-label {
            width: 120px;
        }

        .login-body .layui-form-pane .layui-input-block {
            margin-left: 120px;
        }

    </style>
    <script>
        if (window != top)
            top.location.replace(location.href);
    </script>
</head>

<body>
<div class="login-wrapper">

    <div class="login-header">
        <img src="${ctxPath}/assets/expand/images/logo.png"> ${systemName}
    </div>

    <div class=" login-body">
        <div class="layui-card">
            <div class="layui-card-header">
                <i class="layui-icon layui-icon-engine"></i>&nbsp;&nbsp;找回密码
            </div>
            <form class="layui-card-body layui-form layui-form-pane" action="" method="post">
                <input type="hidden" id="phone" name="phone" value="${user.phone}"/>
                <input type="hidden" id="idcard" name="idcard" value="${user.idcard}"/>
                <div class="layui-form-item">
                    <label class="layui-form-label">新密码</label>
                    <div class="layui-input-block">
                        <input name="newsPassword" id="newsPassword" type="password" lay-verify="required" class="layui-input"
                               placeholder="请输入新密码">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">再次输入</label>
                    <div class="layui-input-block">
                        <input name="againNewsPassword" id="againNewsPassword" type="password" lay-verify="required" class="layui-input"
                               placeholder="请再次输入新密码">
                    </div>
                </div>
                <div class="layui-form-item">
                    <button id="saveButton" class="layui-btn layui-btn-fluid">提交</button>
                </div>
            </form>
        </div>
    </div>
</div>

@/* 加入contextPath属性和session超时的配置 */
<script type="text/javascript">
    var Feng = {
        ctxPath: "",
        addCtx: function (ctx) {
            if (this.ctxPath === "") {
                this.ctxPath = ctx;
            }
        }
    };
    Feng.addCtx("${ctxPath}");
</script>
<script type="text/javascript" src="${ctxPath}/assets/common/layui/layui.js"></script>
<script type="text/javascript" src="${ctxPath}/assets/common/js/common.js"></script>

<script>
    //禁止浏览器前进和后退
    window.history.forward(-1);

    var i = 60;
    layui.use(['layer', 'form', 'ax'], function () {
        var $ = layui.jquery;
        var layer = layui.layer;
        var form = layui.form;
        var $ax = layui.ax;


        //提交
        $("#saveButton").click(function(){
            var phone = $("#phone").val();
            var idcard = $("#idcard").val();
            var newsPassword = $("#newsPassword").val();
            var againNewsPassword = $("#againNewsPassword").val();

            if (newsPassword == "") {
                Feng.error("新密码不能为空")
                $("#newsPassword").focus();
                return false;
            }
            if (againNewsPassword == "") {
                Feng.error("再次输入新密码不能为空")
                $("#againNewsPassword").focus();
                return false;
            }
            if ($("#newsPassword").val() !== $("#againNewsPassword").val()) {
                Feng.error("两次输入密码不一致")
                $("#againNewsPassword").focus();
                return false;
            }

            //提交
            var saveStepAjax = new $ax(Feng.ctxPath + "/mgr/updatePassWord", function (data) {
                if (data.result == "userBlank") {
                    Feng.error("用户不存在")
                    return false;
                }
                if(data.result == "success"){//修改成功，返回登录页面
                    window.location.href = "${ctxPath}/logout";
                }
            })
            saveStepAjax.set("phone", phone);
            saveStepAjax.set("idcard", idcard);
            saveStepAjax.set("newsPassword", newsPassword);
            saveStepAjax.start();
            return false;
        });

    });
</script>


</body>
</html>